﻿Imports System.Windows.Forms
Imports System.Data.Common

Public Class MdiMain
	
	Private _connection As DbConnection
	Private _service_manager As ServiceManager
	Public _pf As New PropertyForm
	Public _ipf As New ImagePreviewForm
	private _config as Configuration = Configuration.GetObject
	Private _sbsf As New SkinsBeStartForm
	
	Public _lwf As ListWallpaperForm
	
	Public Shadows Sub ShowDialog(ByVal connection As DbConnection)
		MyBase.ShowDialog()
		_connection = connection
	End Sub
	
	Private Sub MdiMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
		Dim login As New LoginForm
		_config.Selfcheck()
		login.ShowDialog()
		Me.Focus()
		_connection = login.Connection
		
		_service_manager = ServiceManager.GetServiceManager(_connection)
		
		_sbsf.MdiParent = Me
		_sbsf.WebBrowser1.Navigate("http://www.skins.be")
		_sbsf.Show(DockPanel1)
		
		_lwf = New ListWallpaperForm
		_lwf.Show(DockPanel1)
		_lwf.DockState = WeifenLuo.WinFormsUI.Docking.DockState.DockLeft
		
		_pf.MdiParent = Me
		_pf.Show(DockPanel1)
		_pf.DockState = WeifenLuo.WinFormsUI.Docking.DockState.DockRightAutoHide
		
		
		_ipf.MdiParent = Me
		_ipf.Show(DockPanel1)
		_ipf.DockState = WeifenLuo.WinFormsUI.Docking.DockState.DockLeft
		_ipf.Dock = DockStyle.Bottom
		
		Dim dwf As New DownloadWallpaperForm
		dwf.MdiParent = Me
		dwf.Show(DockPanel1)
		dwf.DockState = WeifenLuo.WinFormsUI.Docking.DockState.DockBottomAutoHide
		
		Refresh()
	End Sub
	
	Private Sub BeendenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
		End
	End Sub
	
	Private Sub BeendenToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BeendenToolStripMenuItem.Click
		End
	End Sub
	
	Private Sub VonSkinsbeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VonSkinsbeToolStripMenuItem.Click
		Dim dsbe As New DownloadSkinsBeForm
		dsbe.Show(DockPanel1)
	End Sub
	
	Private Sub AnhandNameToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AnhandNameToolStripMenuItem.Click
		Dim wrss As New RSSByNameForm
		Dim name As String = InputBox("Bitte geben Sie den Namen des Models im Format [VORNAME]-[NACHNAME] ein.")
		If name <> "" Then
			wrss.Text = Utils.InitCap(name) & " RSS [" & Configuration.GetObject.Resolution & "]"
			wrss.DownloadabeWallpapers = ServiceManager.GetServiceManager.GetWallpaperService.GetListOfNew("http://www.skins.be/feeds/de/" & name & ".xml")
			wrss.Show(DockPanel1)
		End If
	End Sub
	
	Private Sub RSSLinkToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RSSLinkToolStripMenuItem.Click
		Dim wrss As New RSSByNameForm
		Dim rss As String = InputBox("Bitte fügen Sie einen RSS Link von Skins.be ein.")
		If rss <> "" Then
			wrss.TabText = " RSS [" & Configuration.GetObject.Resolution & "]"
			wrss.DownloadabeWallpapers = ServiceManager.GetServiceManager.GetWallpaperService.GetListOfNew(rss)
			wrss.Show(DockPanel1)
		End If
	End Sub
	
	Private Sub InfoToolStripMenuItem_Click( ByVal sender As System.Object,  ByVal e As System.EventArgs) Handles InfoToolStripMenuItem.Click
		MsgBox(Configuration.GetObject.DatabaseType)
	End Sub
	
	Private Sub URLToolStripMenuItem_Click( ByVal sender As System.Object,  ByVal e As System.EventArgs) Handles URLToolStripMenuItem.Click
		Dim difwf As New DownloadImageFromWebFrom
		difwf.MdiParent = Me
		difwf.Show(DockPanel1)
	End Sub
	
	Private Sub EinstellungenToolStripMenuItem_Click( ByVal sender As System.Object,  ByVal e As System.EventArgs) Handles EinstellungenToolStripMenuItem.Click
		Dim cf As New ConfigurationGui
		cf.ShowDialog()
	End Sub
	
	Sub GrafischeÜbersichtToolStripMenuItemClick(sender As Object, e As EventArgs)
		If MsgBox("Diese Übersicht zu laden kann abhängig von der Anzahl der Bilder sehr lange dauern." & vbnewline & _
			"Sicher, das du es weiter durchziehen willst?", MsgBoxStyle.YesNo + msgboxstyle.Question, "Sicher?") = _
			msgboxresult.Yes then
			Dim f As New ModelDetailListForm
			f.TopLevel = False
			f.MdiParent = Me
			f.Show(DockPanel1)
		end if
	End Sub
End Class
